<?php

/**
 * Created by PhpStorm.
 * User: Yieong
 * Date: 16/4/7
 * Time: 上午11:10
 */
class AccountService extends Service {

    public static function getInfo($server, $search){
        $api = new ApiService($server);
        $result = $api->accountInfo($search);

        if($result['state']){
            foreach($result['data'] as &$tmp){
                $tmp['iCreateTime'] = date('Y-m-d H:i:s', $tmp['iCreateTime']);
                $tmp['dwLastLogInTime'] = date('Y-m-d H:i:s', $tmp['dwLastLogInTime']);

                if($tmp['bIsOnline']){
                    $tmp['isOnline'] = '在线';
                }else{
                    $tmp['isOnline'] = '不在线';
                }

                $occupationMap = PubDict::dict('roma', 'roleocc');
                if(isset($occupationMap[$tmp['bOccupation']])){
                    $tmp['occupation'] = $occupationMap[$tmp['bOccupation']];
                }

                $platMap = array(
                    '0' => '无',
                    '1' => '海马',
                    '2' => 'xy'
                );
                $tmp['plat'] = $platMap[$tmp['iPlatID']];

                if(empty($tmp['bBlockChatReason'])){
                    $tmp['bBlockChatReason'] = '';
                }

                if(empty($tmp['iGMPower'])){
                    $tmp['iGMPower'] = '无';
                }else{
                    $tmp['iGMPower'] = '有';
                }
            }
            unset($tmp);

            return array('state' => true, 'data' => $result['data']);
        }else{
            return $result;
        }
    }

}